#ifndef __UTILITY_MATH_H__
#define __UTILITY_MATH_H__
#include <tuple>
#include <utility>
#include <vector>
#include "shader.h"
#include "camera.h"
#include "mat4.h"
#include "vec4.h"
#include "vec3.h"
#include "vec2.h"
#include "bound2.h"

//extern std::tuple<float, float, float> 
//barycentric(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3, const Vec3f& target);

extern std::tuple<float, float, float>
barycentric(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3, const Vec2f& target);

extern bool isInRect(const Vec3f& p, const Bound2i& rect);
extern bool isInTriangle(const Vec2f p1, const Vec2f p2, const Vec2f p3, const Vec2f target);
extern bool needClip(const Vec3f& p1, const Vec3f& p2, const Vec3f& p3, const Bound2i& screen);

extern Bound2i AABBbox(const Vec2f& p1, const Vec2f& p2, const Vec2f& p3);
//extern std::vector<std::pair<int, int>>  bresenhamDrawLine(Vec2f p1, Vec2f p2);

extern std::vector<std::pair<int, int>>
DDALine(const Vec2f& p1, const Vec2f& p2);

extern std::vector<std::tuple<Vec3f, Vec3f, Vec3f>>
SHClipping(const Frustum& f, const Vec3f& p1, const Vec3f& p2, const Vec3f& p3);

extern std::vector<std::tuple<Vertex, Vertex, Vertex>>
clipping(const Vertex& p1, const Vertex& p2, const Vertex& p3);

extern bool backCulling(const std::tuple<Vertex, Vertex, Vertex>& triangle, const Vec3f& lookDir);

extern bool isInNDC(const Vec3f& p1);

#endif
